#include<stdio.h>  
#include<stdlib.h>  

void swap(char &c1, char &c2) {
	char tmp = c1;
	c1 = c2;
	c2 = tmp;
}

int main() {
	int n;
	char str[3], tmp;
	scanf("%d", &n);
	while (n--) {
		scanf("%s", &str);

		if (str[0] > str[1])
			swap(str[0], str[1]);
		if (str[0] > str[2])
			swap(str[0], str[2]);
		if (str[1] > str[2])
			swap(str[1], str[2]);

		printf("%c %c %c\n", str[0], str[1], str[2]);
	}
	return 0;
}
